Use Windows.pkg
Use DFClient.pkg
Use Prnt_dlg.pkg
Use File_dlg.pkg
Use BatchDD.pkg
Use Flexml.pkg
Use SongImport.bp

Deferred_View Activate_oImport for ;
Object oImport is a dbView

    Property String psMboxCaption "Music Import"
    Set Size to 44 355
    Set Location to 2 2
    Set Label to "Import Music"
    Set Border_Style to Border_Thick
    Set Icon to "music.ico"
    
    Object oImportPath is a Form
        Set Size to 13 263
        Set Location to 15 11
        Set Prompt_Button_Mode to PB_PromptOn
        Set peAnchors to anBottomLeftRight
        
        Procedure Prompt
            Boolean bOk
            String sFileName
            
            Get Show_Dialog of oOpenDialog to bOk
            If (bOk) Begin
                Get File_Name of oOpenDialog to sFileName
                Set Value of oImportPath to sFileName
            End
        End_Procedure
    End_Object
    
    Object oOpenDialog is a OpenDialog
        Set Initial_Folder to (psDataPath(phoWorkspace(ghoApplication)))
        Set Filter_String to "Xml|*.xml"
    End_Object

    Object oImportBtn is a Button
        Set Size to 14 69
        Set Location to 7 278
        Set Label to "&Import"
        Set peAnchors to anBottomRight

        Procedure OnClick
            String sFilepath
            Boolean bFail
            
            Get Value of oImportPath to sFilepath
            Get DoImport of oSongImport False sFilepath to bFail
            If (not(bFail)) Send Info_Box "Records successfully imported." (psMboxCaption(Self))
            Else Send Info_Box "Please check XML file path and try again." (psMboxCaption(Self))
        End_Procedure
    
    End_Object

    Object oImport_With_ReportBtn is a Button
        Set Size to 14 69
        Set Location to 23 278
        Set Label to "I&mport With Report"
        Set peAnchors to anBottomRight

        Procedure OnClick
            String sFilepath
            Boolean bFail
            
            Get Value of oImportPath to sFilepath
            Get DoImport of oSongImport True sFilepath to bFail
            If (bFail) Send Info_Box "Please check XML file path and try again." (psMboxCaption(Self))
        End_Procedure
    
    End_Object
    
    On_Key Key_Alt+Key_I Send OnClick of oImportBtn
    On_Key Key_Alt+Key_M Send OnClick of oImport_With_ReportBtn
    
Cd_End_Object
